package mysqlCnnection;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class LogInCheck extends ConnectionTOmysql
{

	private Connection connection;
	
	public LogInCheck() 
	{
		super();
		this.connection = super.getConnection();
	}
	
	/**
	 * This method return the employee role 
	 * @param username
	 * @param password
	 * @return
	 */
	public String passwordAndUserNameCheck(String username, String password)
	{
		Statement stmt;
		try
		{
			stmt = connection.createStatement();
			ResultSet rs = stmt.executeQuery("SELECT duty FROM employees WHERE epassword = '"+password+"' AND eusername = '"+username+"';");
			String str = "";
			if (rs.next())
			{
				 str = rs.getString(1);
				 rs.close();
			} 
			else
				str = "Ilegalusername";			
			return str;
		} catch (SQLException e)
		{
			return null;
		}		
	}
	
	
}
